package com.fs.system.security;

import cn.hutool.core.convert.Convert;
import com.fs.common.util.sign.PasswordUtils;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @author suke
 * @version 1.0
 * @title MyPasswordEncoder
 * @description  自定义的密码编码
 * @create 2024/7/25 10:58
 */
public class MyPasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence rawPassword) {
        return PasswordUtils.generate(Convert.toStr(rawPassword));
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return PasswordUtils.verify(Convert.toStr(rawPassword),encodedPassword);
    }
}
